package com.tencent.iov.cowin.befsale.clue.controller.clue;


import com.tencent.iov.cowin.befsale.clue.controller.clue.assembler.ClueIntentionVehicleAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.AddClueIntentionVehicleRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.DeleteClueIntentionVehicleRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.QueryClueIntentionVehicleRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.UpdateClueIntentionVehicleRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueIntentionVehicleResponse;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.ClueIntentionVehicle;
import com.tencent.iov.cowin.befsale.clue.service.clue.ClueIntentionVehicleService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 意向车车型_Controller层
 * @author: xiamu
 * @created: 2022-01-06 14:53:55
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/demo/clueIntentionVehicle", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "意向车车型_Controller层")
public class ClueIntentionVehicleController {
	
	@Autowired
	private ClueIntentionVehicleService clueIntentionVehicleService;

	/**
	 * 通过ID获取详细信息
	 *
	 * @param: id
	 * @return: ClueIntentionVehicle对象
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
	@RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
	public Response<ClueIntentionVehicleResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1")  @RequestParam("id") Long id) {
		return Response.success(ClueIntentionVehicleAssembler.transformPOToResponseVo(clueIntentionVehicleService.getDetailById(id), ClueIntentionVehicleResponse.class));
	}

	/**
	 * 单条数据插入ClueIntentionVehicle
	 * @param request
	 * @return 插入的条数
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
	@RequestMapping(path = "/add", method = RequestMethod.POST)
	public Response<Long> add(@Valid @RequestBody AddClueIntentionVehicleRequest request) {
		return Response.success(clueIntentionVehicleService.insert(ClueIntentionVehicleAssembler.transformVOToPO(request, ClueIntentionVehicle.class)));
	}

	/**
	 * 批量插入ClueIntentionVehicle
	 * @param requests
	 * @return 批量插入的条数
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-批量插入ClueIntentionVehicle接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
	@RequestMapping(path = "/add_batch", method = RequestMethod.POST)
	public Response<Integer> addBatch(@Valid @RequestBody List<QueryClueIntentionVehicleRequest> requests) {
		return Response.success(clueIntentionVehicleService.insertBatch(ClueIntentionVehicleAssembler.transformPOToResponseVoList(requests, ClueIntentionVehicle.class)));
	}

	/**
	 * 通过ID修改信息接口
	 *
	 * @param: request
	 * @return: 修改的条数
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
	@RequestMapping(path = "/update", method = RequestMethod.POST)
	public Response<Integer> update(@Valid @RequestBody UpdateClueIntentionVehicleRequest request) {
		return Response.success(clueIntentionVehicleService.update(ClueIntentionVehicleAssembler.transformVOToPO(request, ClueIntentionVehicle.class)));
	}

	/**
	 * 通过ID删除数据
	 * @param request
	 * @return 删除的条数
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
	@RequestMapping(path = "/delete", method = RequestMethod.POST)
	public Response<Integer> delete(@Valid @RequestBody DeleteClueIntentionVehicleRequest request) {
		return Response.success(clueIntentionVehicleService.delete(ClueIntentionVehicleAssembler.transformVOToPO(request, ClueIntentionVehicle.class)));
	}

	/**
	 * 根据条件查询对象list列表
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
	@RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
	public Response<List<ClueIntentionVehicleResponse>> getListByParam(@RequestBody QueryClueIntentionVehicleRequest request) {
		List<ClueIntentionVehicle> responseList = clueIntentionVehicleService.getListByParam(ClueIntentionVehicleAssembler.transformVOToPO(request, ClueIntentionVehicle.class));
		return Response.success(ClueIntentionVehicleAssembler.transformPOToResponseVoList(responseList, ClueIntentionVehicleResponse.class));
	}

	/**
	 * 根据条件查询对象Page记录
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
	public Response<PageResponse<ClueIntentionVehicleResponse>> getPageByParam(@RequestBody PageRequest<QueryClueIntentionVehicleRequest> request) {
		PageResponse<ClueIntentionVehicle> clueIntentionVehiclePageResponse = clueIntentionVehicleService.getPageByParam(ClueIntentionVehicleAssembler.transformVOToPOPage(request, ClueIntentionVehicle.class));
		return Response.success(ClueIntentionVehicleAssembler.transformPOToResponseVoPage(clueIntentionVehiclePageResponse, ClueIntentionVehicleResponse.class));
	}

	/**
	 * 根据条件查询单个对象
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueIntentionVehicle管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_one_by_param", method = RequestMethod.POST)
	public Response<ClueIntentionVehicleResponse> getOneByParam(@RequestBody QueryClueIntentionVehicleRequest request){
		ClueIntentionVehicle clueIntentionVehicle = clueIntentionVehicleService.getOneByParam(ClueIntentionVehicleAssembler.transformVOToPO(request, ClueIntentionVehicle.class));
		return Response.success(ClueIntentionVehicleAssembler.transformPOToResponseVo(clueIntentionVehicle, ClueIntentionVehicleResponse.class));
	}
}